<%@page pageEncoding="UTF-8" language="java" contentType="text/html; UTF-8"  %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<%--<link href="../../../jquery/bootstrap_3.3.0/css/bootstrap.min.css" type="text/css" rel="stylesheet" />--%>
	<%--使用虚拟机打开使用绝对路径--%>
<link href="${pageContext.request.contextPath}/jquery/bootstrap_3.3.0/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery/jquery-1.11.1-min.js"></script>
	<%--jQuery.md5.js  jquery组件 必须要放在 jquery的基础文件下方 --%>
	<script type="text/javascript" src="${pageContext.request.contextPath}/jquery/jQuery.md5.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/jquery/bootstrap_3.3.0/js/bootstrap.min.js"></script>

	<script>
		$(function () {
			//给整个浏览器窗口添加键盘按下事件 回车登录
			$(window).keydown(function (event) {  //event 事件本身
				//如果按的是回车键 则提交登录请求
				if (event.which === 13) {
					$("#loginBut").click();
				}
			});

			$("#loginBut").click(function () {
				var loginAct = $("#loginAct").val();
				var loginPwd = $("#loginPwd").val();
				if (loginAct==''||loginPwd==''){
					$("#msg").text("账号，密码不能为空")
					return;
				}
				/*判断 密码需不需要加密*/
				if (loginPwd.length!=32){
					loginPwd=$.md5(loginPwd);
				}
				$.ajax({
					url:"../doLogin",
					dataType:"json",
					type:"post",
					data:{
						loginAct:loginAct,
						loginPwd:loginPwd,
						rememberMe: $("#rememberMe").prop("checked") // checked 选中为true
					},
					success:function (result) {
						if (result.code==2000){
						//	页面跳转
							window.location.href="/index";
						}else {
							//	提示 错信息
							$("#msg").text(result.msg)
						}
					},beforeSend: function() {
						$("#msg").text(" 登录中，请稍等....");
						return true;
					}

				});
			});
		});
	</script>
</head>
<body>
	<div style="position: absolute; top: 0px; left: 0px; width: 60%;">
		<img src="${pageContext.request.contextPath}/image/IMG_7114.JPG" style="width: 100%; height: 90%; position: relative; top: 50px;">
	</div>
	<div id="top" style="height: 50px; background-color: #3C3C3C; width: 100%;">
		<div style="position: absolute; top: 5px; left: 0px; font-size: 30px; font-weight: 400; color: white; font-family: 'times new roman'">CRM &nbsp;<span style="font-size: 12px;">&copy;2019&nbsp;动力节点</span></div>
	</div>
	<div style="position: absolute; top: 120px; right: 100px;width:450px;height:400px;border:1px solid #D5D5D5">
		<div style="position: absolute; top: 0px; right: 60px;">
			<div class="page-header">
				<h1>登录</h1>
			</div>
			<form action="${pageContext.request.contextPath}/index" class="form-horizontal" role="form">
				<div class="form-group form-group-lg">
					<div style="width: 350px;">
						<input id="loginAct" value="${cookie.loginAct.value}" class="form-control" type="text" placeholder="用户名">
					</div>
					<div style="width: 350px; position: relative;top: 20px;">
						<input id="loginPwd" value="${cookie.loginPwd.value}" class="form-control" type="password" placeholder="密码">
					</div>
					<div class="checkbox"  style="position: relative;top: 30px; left: 10px;">
						<label>
							<c:if test="${cookie.loginAct.value!=null}">
								<input type="checkbox" id="rememberMe" checked> 十天内免登录
							</c:if>
							<c:if test="${cookie.loginAct.value==null}">
								<input type="checkbox" id="rememberMe"> 十天内免登录
							</c:if>
						</label>
						<span id="msg" style="color: red"></span>
					</div>
					<button type="button" id="loginBut" class="btn btn-primary btn-lg btn-block"  style="width: 350px; position: relative;top: 45px;">登录</button>
				</div>
			</form>
		</div>
	</div>
</body>
</html>